package com.tenebrous.jestic.controller.framwork.system.logs;

import com.tenebrous.jestic.controller.SupperController;
import com.tenebrous.jestic.service.framwork.system.SysLogService;
import com.rain.ops.sdk.dto.ApiResult;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

/**
 * 变更日志
 */
@Validated
@RestController
@RequestMapping("/log/modify")
public class ModifyLogController extends SupperController {

    @Autowired
    private SysLogService logService;

    /**
     * 查询
     *
     * @return
     */
    @PostMapping("/paging")
    public ApiResult paging(String batch) {
        return new ApiResult(200, "查询成功。", logService.queryModifyLogPagingList(super.getPageIndex(), super.getPageSize(), batch));
    }

    /**
     * 回撤操作
     * @param id
     * @return
     */
    @SneakyThrows
    @PostMapping("/revoke")
    public ApiResult revoke(@NotBlank String id) {
        return new ApiResult(200, "回撤成功。", logService.revokeModifyLogItem(id));
    }
}
